package com.ats.audiotoscore;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import java.io.BufferedReader;
import java.io.FileReader;

public class Utils {
	public static int GetCPUSpeed() {
		String str = "0";
		try {
			BufferedReader br = new BufferedReader(new FileReader("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"));
	    	try {
	    		str = br.readLine();
	    	} finally {
	    		br.close();
	    	}
		} catch (Exception e) {
			System.err.println(e);
		}

		return Integer.parseInt(str);
	}

    public static boolean IsDebugMode(Context ctx) {
        boolean debuggable = false;
     
        PackageManager pm = ctx.getPackageManager();
        try {
            ApplicationInfo appinfo = pm.getApplicationInfo(ctx.getPackageName(), 0);
            debuggable = (0 != (appinfo.flags &= ApplicationInfo.FLAG_DEBUGGABLE));
        } catch(NameNotFoundException e) {
            /*debuggable variable will remain false*/
        }
         
        return debuggable;
    }
}
